package com.gongJiao.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *全局返回类
 * @author Administrator
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    private String code;
    private String message;
    private Object data;

    public static Result success(String code, String message, Object data){
        Result result=new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    public static Result success(String message, Object data){
        Result result=new Result();
        result.setCode("200");
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    public static Result success(Object data){
        Result result = new Result();
        result.setCode("200");
        result.setMessage("操作成功");
        result.setData(data);
        return result;
    }
    public static Result success(String message){
        Result result = new Result();
        result.setCode("200");
        result.setMessage(message);
        return result;
    }
    public static Result fail(String code, String message, Object data){
        Result result=new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
    public static Result fail(String message){
        Result result = new Result();
        result.setCode("400");
        result.setMessage(message);
        return result;
    }
}
